Python - Returning a traversed matrix using recursion